package com.mall.xiaomi.controller;

import com.mall.xiaomi.pojo.Carousel;
import com.mall.xiaomi.service.CarouselService;
import com.mall.xiaomi.util.ResultMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName CarouselController
 * @Description TODO
 * @action luoliang
 * @Data 2021/2/24 14:40
 * @Version 1.0
 */
@RestController

public class CarouselController {

    @Autowired
    private CarouselService carouselService;
    @Autowired
    private ResultMessage resultMessage;

    @GetMapping("/resources/carousel")
    public ResultMessage carousels(){
        List<Carousel> carousels = carouselService.selectAll();
        if (carousels != null){
            resultMessage.success("200", carousels);
            return resultMessage;
        }else {
            resultMessage.success("400", null);
            return resultMessage;
        }

    }
}
